Detail = function() {
	return {
		
		initAreaField : function() {
			var districtId = $("#districtId_hidden").val();
			var cityId = $("#cityId_hidden").val();
			var provinceId = $("#provinceId_hidden").val();
			$('#province').combobox({
				url           : '/pc/provinces/getProvinces.htm',
				valueField    : "id",
				textField     : "province",
				editable      : false,
				panelHeight   : 250,
				onLoadSuccess : function() {
					$('#province').combobox("setValue", provinceId);
				},
				onSelect      : function(value) {
					Detail.cityCombobox(value.id, "");
					Detail.areaCombobox("", "");
				}
			});
			Detail.cityCombobox(provinceId, cityId);
			Detail.areaCombobox(cityId, districtId);
		},
		
		cityCombobox : function(provinceId, cityId) {
			$('#city').combobox({
				url           : '/pc/cities/getCities.htm?provinceId=' + provinceId,
				valueField    : 'id',
				textField     : 'city',
				editable      : false,
				panelHeight   : 250,
				onLoadSuccess : function() {
					$('#city').combobox("setValue", cityId);
				},
				onSelect      : function(value) {
					Detail.areaCombobox(value.id, "");
				}
			});
		},
		
		areaCombobox : function(cityId, districtId) {
			$('#district').combobox({
				url         : '/pc/areas/getAreas.htm?cityId=' + cityId,
				valueField  : 'id',
				textField   : 'area',
				editable    : false,
				panelHeight : 250,
				onLoadSuccess : function() {
					$('#district').combobox("setValue", districtId);
				}
			});
		},
		
		/**
		 * 初始化频道、行业、服务项目信息.
		 */
		initServiceField : function() {
			var channelId = $("#channelId_hidden").val();
			var industryId = $("#industryId_hidden").val();
			var serviceItemId = $("#serviceItemId_hidden").val();
			$('#channel').combobox({
				url           : '/pc/channel/channels.htm',
				valueField    : "channelId",
				textField     : "channelName",
				editable      : false,
				panelHeight   : 'auto',
				onLoadSuccess : function() {
					$('#channel').combobox("setValue", channelId);
				},
				onSelect      : function(value) {
					Detail.industryCombobox(value.channelId, "");
					Detail.serviceItemCombobox("", "");
				}
			});
			Detail.industryCombobox(channelId, industryId);
			Detail.serviceItemCombobox(industryId, serviceItemId);
		},
		
		industryCombobox : function(channelId, industryId) {
			$('#industry').combobox({
				url           : '/pc/industry/industrys.htm?channelId=' + channelId,
				valueField    : "industryId",
				textField     : "industryName",
				editable      : false,
				panelHeight   : 200,
				onLoadSuccess : function() {
					$('#industry').combobox("setValue", industryId);
				},
				onSelect      : function(value) {
					Detail.serviceItemCombobox(value.industryId, "");
				}
			});
		},
		
		serviceItemCombobox : function(industryId, serviceItemId) {
			$('#serviceItem').combobox({
				url           : '/pc/serviceItem/serviceItems.htm?industryId=' + industryId,
				valueField    : "serviceItemId",
				textField     : "serviceItemName",
				editable      : false,
				panelHeight   : 200,
				onLoadSuccess : function() {
					$('#serviceItem').combobox("setValue", serviceItemId);
				}
			});
		},
		
		closeTab : function() {
			window.parent.Ict.closeSelectedTab();
		}
	};
}();

$(function(){
	Detail.initAreaField();
	Detail.initServiceField();
});